package com.transaction.manage.localMapper;

import com.transaction.manage.model.dto.FundRelation;
import com.transaction.manage.myMapper.MyMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface FundRelationMapper extends MyMapper<FundRelation> {

    @Update("UPDATE fund_relation SET valid_flag = '00' ,check_flag = '00' WHERE channel_code = #{channelCode} AND fund_code = #{fundCode} AND ta_fund_code = #{taFundCode}")
    void deleteFundRelation(@Param("channelCode") String channelCode, @Param("fundCode") String fundCode, @Param("taFundCode") String taFundCode);

    @Update("UPDATE fund_relation SET check_flag = '01' WHERE channel_code = #{channelCode} AND fund_code = #{fundCode} AND ta_fund_code = #{taFundCode} ")
    void checkFundRelation(@Param("channelCode") String channelCode,@Param("fundCode") String fundCode, @Param("taFundCode") String taFundCode);

    List<FundRelation> selectFundRelationList(FundRelation fundRelation);

    void insertFundRelation(FundRelation fundRelation);

    void updateFundRelation(FundRelation fundRelation);

    void updateFundRelationByChannelAndFundAndTaFundCode(FundRelation fundRelation);

    FundRelation selectFundRelationByChannelAndFundAndTaFundCode(@Param("channelCode") String channelCode,@Param("fundCode") String fundCode, @Param("taFundCode") String taFundCode);

    @Select("select ta_fund_code from fund_relation WHERE channel_code = #{channelCode} AND fund_code = #{fundCode} and valid_flag != '00' and check_flag = '01' ")
    List<String> selectTaFundCodeList(@Param("channelCode") String channelCode,@Param("fundCode") String fundCode);
}